
<template>
	<!-- 添加弹框 -->
		<el-dialog title="" visible :show-close="false" :append-to-body="true"  class="wrap">
        <i class="el-icon-close close" @click="cancel" style="color: white;z-index:10;"></i>
	    <div class="bt">分类添加</div>
	    <el-form label-width="100px" class="form">
		<el-form-item label="序号">
 				<el-input v-model="vxh"  placeholder="请输入分类序号" class="select-block"></el-input>
 		</el-form-item>
		<el-form-item label="分类名称">
 				<el-input v-model="vmc" placeholder="请输入分类名称" class="select-block"></el-input>
 		</el-form-item>
 		<div class="an">
		<el-button type="primary" class="submit" @click="submit">保存</el-button>
		<el-button type="danger" class="submit" @click="cancel">退出</el-button>
		</div>

		</el-form>
	</el-dialog>
</template>
<script type="text/javascript">
	import qs from 'qs'
	export default {
		props: ['params'],
		data() {
			return {
				vxh:'',
				vmc:'',
			}
		},
		created(){
	    },
		methods: {
			submit() {
				//检测
				this.$store.state.loading = true;
			    if(!this.vxh) {
					this.$message.warning('请输入序号');
					this.$store.state.loading = false;
					return;
				}
			    else if(!this.vmc){
					this.$message.warning('请输入分类名称');
					this.$store.state.loading = false;
					return;
				}
				var logininfo = JSON.parse(localStorage.logininfo);
				var params3 = qs.stringify({
					xh:this.vxh,
					mc:this.vmc,
					yhid: logininfo.id,
					xxid:logininfo.xxid
				});
				//执行
				this.axios.post(this.$store.state.api + 'cwzcfl/insert', params3)
					.then(res => {
						if(res.data.code == 1) {
							this.$emit('close', { type: 'add', cancel: false });
							this.$store.state.loading = false;
						} else {
						    this.$message.warning(res.data.msg);
							this.$store.state.loading = false;
						}
					}).catch(res => {
						this.$message.warning("服务器繁忙，请重试");
						this.$store.state.loading = false;
					})
			},
			cancel() {
				this.$emit('close', { type: 'add', cancel: true })
			},
		}
	}
</script>
<style lang="less" scoped>
	.wrap {
		.input-block {
			margin-bottom: 20px;
			text-align: center;
		}
		.bt{
		position: absolute;
		width: 100%;
		height: 50px;
		margin: 0 auto;
		top: 0;
		left: 0;
		background: #50BFFF;
		color:white;
		text-align:left;
		line-height: 50px;
		font-size: 17px;
		padding-left: 15px;
	}

.form {
	text-align: left;
	margin-top: 10px;
}
		.input {
			width: 62%;
			display: inline-block;
		}
		/*.input1 {
			width: 90%;
			display: inline-block;
		}
		.input2 {
			width: 90;
			display: inline-block;
			vertical-align: middle;
		}*/
		.input-block span {
			display: inline-block;
			width: 100px;
			text-align: right;
		}
		.select-block {
	// display: block;
	float: left;
	width: 85%;
}
		.submit {
			width: 120px;
		}
		.wpfl{
			background: #fff;
			position: absolute;
			top: 5px;
			left: 5px;
		}
	}
	.an{
		width: 100%;
		text-align: center;
	}
</style>
